<template>
  <div class="scorecreatewrapper zanwei-top">
    <head-nav></head-nav>
    <div class="scorecreate" v-if="rowobj">
      <div class="scorecreate-top-img">
        <img v-if="rowobj.XQT[0]" :src="rowobj.XQT[0]"/>
      </div>
      <div class="scorecreate-top">
        <h3>{{rowobj.LPMC}}</h3>
        <span>{{rowobj.JF}}积分</span>
        <!-- <b>会员： mm7832666</b> -->
        <p>恭喜您兑换成功！</p>
      </div>
      <div class="scorecreate-bottom">
        <!-- <div class="qrcode" id="qrcode">
        </div>
        <p>验证码已经生成，请凭验证码及有效证件至五楼贵宾厅兑换领取。</p> -->
        <div class="gogame" @click="gogame()">去游戏</div>
      </div>
    </div>
    <div class="zanwei-bottom"></div>
    <!-- 底部导航 -->
    <!-- <foot-nav></foot-nav> -->
  </div>
</template>

<script>
  import api from '@/api/api'
  import {MessageBox, Toast} from 'mint-ui';

  var sss;

  export default {
    data() {
      return {
        rowobj: null
      }
    },
    methods: {
      gogame() {
        if (!this.$util.checkValidity()) {
          return
        }
        window.location.href = `http://${this.isRelUrl}.ruitaianke.com/wx_next_bind.action?redirect=wx_user_bind.action?url=http://${this.isRelUrl}.ruitaianke.com/joinGame.action?lpid=` + this.rowobj.LPID;
      },
      checkHX(pdid) {
        let page = this
        var userinfo = JSON.parse(sessionStorage.getItem('userinfo'));
        /**
         * 查询一个我的订单
         * @param page
         * @param cb
         * @param userid 用户卡号
         * @param oid 订单id
         */
        api.getUserOrder(page, cb, userinfo.vipcode, pdid, "hx")

        function cb(res) {

          let re = res.data
          if (re.code == 0) {
            let data = JSON.parse(re.data)
            let hx = data.SFHX
            if (hx == 1) {
              clearInterval(sss)
              Toast({
                message: "已核销",
                iconClass: 'iconfont icon-duigou yhx',
                duration: 3000
              });
              setTimeout(function () {
                page.$router.push('/wallet')
              }, 3000)
            }

          } else {
            Toast({
              message: re.msg,
              duration: 3000
            });
          }
        }
      }
    },
    mounted() {
      let page = this
      if (!this.$util.checkValidity()) {
        return
      }
      if (Object.getOwnPropertyNames(this.$route.query).length !== 0 && this.$route.query.create !== '[object Object]') {
        let create = this.$route.query.create
        let pdid = create.pdid
        var userinfo = JSON.parse(sessionStorage.getItem('userinfo'));
        /**
         * 查询一个我的订单
         * @param page
         * @param cb
         * @param userid 用户卡号
         * @param oid 订单id
         */
        api.getUserOrder(page, cb, userinfo.vipcode, pdid, "hx")

        function cb(res) {

          let re = res.data
          if (re.code == 0) {
            let data = JSON.parse(re.data)
            console.log('wod ee')
            console.log(data)
            let XQT = data.XQT.map(x => {
              return page.host.filehost + x
            })
            data.XQT = XQT
            page.rowobj = data

          } else {
            Toast({
              message: re.msg,
              duration: 3000
            });
          }
        }


      } else {
        console.log('xixixi2')
      }

    },
    destroyed() {
      clearInterval(sss)
    }
  }
</script>

<style lang="less">
  .yhx {
    font-size: 0.55rem;
  }

  .scorecreatewrapper {
    .scorecreate {
      .scorecreate-top-img {
        /* width: 4.4rem;
        height: 1.7rem;
        border: #cbcbcc solid 1px;
        margin-top: 1.12rem;
        margin-bottom: 0.6rem; */
        width: 100%;
        height: 4rem;
        /* border: #cbcbcc solid 1px; */
        margin-bottom: 0.4rem;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .scorecreate-top {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 0 0.2rem;

        &::before {
          content: "";
          position: absolute;
          z-index: 2;
          bottom: 0;
          left: 0px;
          width: 100%;
          height: 1px;
          border-bottom: 1px dashed #F05DC4;
          transform: scaleY(0.5);
          transform-origin: 0 100%;
        }

        h3 {
          font-size: 0.32rem;
          color: #000000;
        }

        span {
          color: #F05DC4;
          font-size: 0.32rem;
          margin-top: 0.2rem;
          margin-bottom: 0.6rem;
        }

        b {
          display: block;
          color: #000000;
          font-size: 0.24rem;
        }

        p {
          color: #F05DC4;
          font-size: 0.32rem;
          margin-top: 0.04rem;
          margin-bottom: 0.2rem;
          text-indent: 0.28rem;
        }
      }

      .scorecreate-bottom {
        display: flex;
        flex-direction: column;
        align-items: center;

        .qrcode {
          width: 2.8rem;
          height: 2.8rem;
          /* border: #cbcbcc solid 1px; */
          margin-top: 0.3rem;
          margin-bottom: 0.3rem;

          img {
            width: 100%;
            height: 100%;
          }
        }

        p {
          width: 4.56rem;
          font-size: 0.24rem;
          color: #000000;
          text-align: center;
        }
      }
    }
  }

  .gogame {
    width: 80%;
    height: 0.8rem;
    border-radius: 0.1rem;
    background: #F05DC4;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #ffffff;
    font-size: 0.32rem;
    margin-top: 1.6rem;
  }
</style>
